<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>Document</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/page1.css">
    <link rel="stylesheet" href="css/fly.css">
    <script src="js/jquery-1.12.4.min.js"></script>
    <script>
         // viewport 设置
        // 针对原来高清方案的基础, 增加了根据屏幕宽度计算不同font-size 来达到对不同屏幕的适配
        var win = window;
        win.flex = function (baseFontSize, fontscale) {
            var targetWidth = 375;
            var screenWidth = win.screen.width;
            var _baseFontSize = (baseFontSize || 100) * screenWidth / targetWidth;
            var _fontscale = fontscale || 1;

            var doc = win.document;
            var ua = navigator.userAgent;
            var matches = ua.match(/Android[\S\s]+AppleWebkit\/(\d{3})/i);
            var UCversion = ua.match(/U3\/((\d+|\.){5,})/i);
            var isUCHd = UCversion && parseInt(UCversion[1].split('.').join(''), 10) >= 80;
            var isIos = navigator.appVersion.match(/(iphone|ipad|ipod)/gi);
            var dpr = win.devicePixelRatio || 1;
            if (!isIos && !(matches && matches[1] > 534) && !isUCHd) {
                //在部分4.3及以下安卓机型中，screen.width是物理像素宽度，暂时没有找到准确判断的方法，所以不做针对375宽度的缩放
                _baseFontSize = baseFontSize || 100;
                // 如果非iOS, 非Android4.3以上, 非UC内核, 就不执行高清, dpr设为1;
                dpr = 1;
            }


            var scale = 1 / dpr;

            var metaEl = doc.querySelector('meta[name="viewport"]');
            if (!metaEl) {
                metaEl = doc.createElement('meta');
                metaEl.setAttribute('name', 'viewport');
                doc.head.appendChild(metaEl);
            }
            metaEl.setAttribute('content', 'width=device-width,user-scalable=no,initial-scale=' + scale +
                ',maximum-scale=' + scale + ',minimum-scale=' + scale);
            doc.documentElement.style.fontSize = _baseFontSize / 2 * dpr * _fontscale + 'px';
        };

        flex(100, 1);
    </script>
</head>

<body>

    <div id="page1" style="display: block">
        <div class="page1_top">
            <img src="./assets/images/page1/page1_top_bg_01.png" alt="">
        </div>
        <div class="page1_cen">
            <img src="./assets/images/page1/page1_cen_bg_02.png" alt="">
            <div class="shine_line">
            </div>
            <div class="heart_face smile_face">

            </div>
            <div class="arrow fly_arrow">

            </div>
        </div>
        <div class="page1_bottom">
            <!-- <img src="./assets/images/page1/page1_bottom_bg_03.png" alt=""> -->
            <div class="title ">
                <img src="./assets/images/page1/title_content_05.png" class="title_content scale_title" alt="">
            </div>
            <div class="unopened move_unopened">
            </div>
        </div>
        <div class="open">
                <div class="open_icon">

                </div>
                <div class="hand move_hand">
                </div>
            </div>
            <div class="yellow_circle">
            </div>
    </div>


</body>
<script>
    $(document).ready(function () {



        var $page1btn = $("#page1 .open_icon")
        var $page1open = $("#page1 .open")
        console.log("$page1open", $page1open)
        var page1startX,
        page1startY,
        page1distance,
        page1maxX,
        page1openWidth,
        page1iconWidth;
        page1openWidth = $page1open.width();
        page1iconWidth = $page1btn.width();

        console.log("page1openWidth", page1openWidth)
        console.log("page1iconWidth", page1iconWidth)


        page1maxX = page1openWidth - page1iconWidth;
        // console.log("maxX", maxX)

        $page1open.on("touchstart", function (e) {
            // console.log("e", e)
            page1startX = e.originalEvent.changedTouches[0].pageX;
            // console.log("startX", startX)
        });

        $page1open.on("touchmove", function (e) {


            var page1openLeft = $page1open.offset().left;
            // console.log("openLeft", openLeft)
            var page1iconLeft = $page1btn.offset().left;
            if (page1iconLeft >= page1openLeft + page1openWidth - page1iconWidth) {
                return;
            } else {
                page1moveEndX = e.originalEvent.changedTouches[0].pageX;
                page1x = page1moveEndX - page1startX;
                if (0 < page1x < page1maxX) {
                    $page1btn.css('left', page1x);
                }
            }


        });

        $page1open.on("touchend", function (e) {

            var page1openWidth = $page1open.width();
            var page1iconWidth = $page1btn.width()
            var page1openLeft = $page1open.offset().left;
            // console.log("openLeft", openLeft)
            var page1iconLeft = $page1btn.offset().left;
            if (page1iconLeft >= page1openLeft + page1openWidth - page1iconWidth) {
                window.location.href = "./page2.html"
                return;
            } else {
                $page1btn.css('left', -2);
            }


        });



    });
</script>

</html>